//引包 vue vue-resource vue-router
import Vue from 'vue';
import VueRouter from 'vue-router'; //路由对象、锚点值做对应页面的显示通过router-view
import VueResource from 'vue-resource'; //发送ajax请求的对象
//引入主体组件
import App from './components/app.vue';
//引入路由需要的组件
import Home from './components/home.vue';
import Login from './components/login.vue';
import Chatroom from './components/chatroom.vue';


//2:安装插件
Vue.use(VueRouter);
Vue.use(VueResource); //这个对象就可以直接用

//创建对象
let router = new VueRouter({
    routes: [
        { name: 'home', path: '', component: Home }, {
            name: 'login',
            path: '/login',
            component: Login
        }, {
            name: 'chatroom',
            path: '/chatroom',
            component: Chatroom
        },
    ]
});
//第二种方式
// router.addRoutes([
//     { name: 'home', component: Home },
//     { name: 'login', component: Login },
//     { name: 'chatroom', component: Chatroom },
// ]);

new Vue({
    el: '#app',
    router,
    render: c => c(App)
});
